FROM python:3.11-slim

# 设置工作目录
WORKDIR /app

# 安装编译依赖
RUN apt-get update && apt-get install -y gcc

# 复制C源代码并编译
COPY ./string_processor /app/string_processor
RUN cd /app/string_processor && \
    gcc -shared -o ../lib/libstr.so -fPIC string_processor.c

# 安装Python依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

# 复制应用代码
COPY ./app /app/app
COPY ./lib /app/lib

# 暴露端口
EXPOSE 5000

# 启动服务
CMD ["python", "./app/data_service.py"]